package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("note.txt" );
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("开始输入内容，单独输出exit退出");
            String s = sc.nextLine();
            byte[] data = s.getBytes(StandardCharsets.UTF_8);
            if ( "exit".equalsIgnoreCase(s)  ) {// equalsIgnoreCase() 忽略大小写
                System.out.println("退出程序");
                break;
            } else {
                fos.write(data);
                System.out.println("输入成功！");
            }
        }
        fos.close();
    }
}
